package com.stellar.circle.controller.miniApp.sChatRelationship;

import com.stellar.circle.controller.admin.sChatRelationship.vo.SChatRelationshipResponseVO;
import com.stellar.circle.domain.sChatRelationship.SChatRelationshipDomainService;
import com.stellar.web.core.bean.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户聊天关系控制器
 *
 * @author Jqchan
 * @version 1.0
 * @date 2025-06-12 21:21:20
 */
@RequestMapping("/api-miniApp/sChatRelationship")
@RestController("miniAppSChatRelationshipController")
@Slf4j
public class SChatRelationshipController {

    @Resource
    private SChatRelationshipDomainService sChatRelationshipDomainService;

    /**
     * 添加好友关系
     *
     * @param userId   用户ID
     * @param friendId 好友ID
     */
    @PostMapping("/addFriend")
    public Result<Boolean> addFriend(@RequestParam Long userId,
                                     @RequestParam Long friendId) {
        return Result.success(sChatRelationshipDomainService.addFriend(userId, friendId));
    }

    /**
     * 删除好友关系
     */
    @DeleteMapping("/deleteFriend/{userId}/{friendId}")
    public Result<Boolean> deleteFriend(@PathVariable("userId") Long userId, @PathVariable("friendId") Long friendId) {
        return Result.success(sChatRelationshipDomainService.deleteFriend(userId, friendId));
    }

    /**
     * 拉黑/解除拉黑好友
     *
     * @param userId   用户ID
     * @param friendId 被拉黑的用户ID
     */
    @PostMapping("/blockOrUnblock")
    public Result<Boolean> blockOrUnblock(@RequestParam Long userId,
                                          @RequestParam Long friendId) {
        return Result.success(sChatRelationshipDomainService.blockOrUnblock(userId, friendId));
    }

    /**
     * 获取好友列表
     */
    @GetMapping("/list/{userId}")
    public Result<List<SChatRelationshipResponseVO>> list(@PathVariable("userId") Long userId) {
        return Result.success(sChatRelationshipDomainService.list(userId));
    }

    /**
     * 获取关注量/粉丝量/拉黑量
     */
    @GetMapping("/getFollowAndFansCount")
    public Result<SChatRelationshipResponseVO> getFollowAndFansCount(@RequestParam Long userId) {
        return Result.success(sChatRelationshipDomainService.getFollowAndFansCount(userId));
    }
}